/*
=======================================================================

  BOTS Nurse Commands menu

=======================================================================
*/
#include "ui_local.h"
#include "ui_BOTS.h"

#define BOTS_NURSE_CREATE		1
#define BOTS_NURSE_POISON		2
#define BOTS_NURSE_HEAL			3
#define BOTS_NURSE_HEALRADIUS	4

typedef struct 
{
  menuframework_s menu;  

  menutext_s	title;
  menutext_s	poison;
  menutext_s	heal;
  menutext_s	healradius;
  menutext_s	create;
  menutext_s	cancel;
} nurseCommands_t;

static nurseCommands_t		s_nurse;

/*
=================
BOTS_NurseCommandsMenu_Event
callback routine
=================
*/
void BOTS_NurseCommandsMenu_Event( void *ptr, int notification ) 
{
	if( notification != QM_ACTIVATED )
		return;

	// any event will kill the menu
	UI_PopMenu();

	switch( ((menucommon_s*)ptr)->id ) 
	{
	case BOTS_CANCEL:
		break;
	case BOTS_NURSE_CREATE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "create\n" );
		break;
	case BOTS_NURSE_POISON:
		trap_Cmd_ExecuteText( EXEC_APPEND, "poison\n" );
		break;
	case BOTS_NURSE_HEAL:
		trap_Cmd_ExecuteText( EXEC_APPEND, "heal\n" );
		break;
	case BOTS_NURSE_HEALRADIUS:
		trap_Cmd_ExecuteText( EXEC_APPEND, "healradius\n" );
		break;

	// oops - not a valid choice
	default:
		Com_Printf("%i is not a valid choice\n", ((menucommon_s*)ptr)->id);
		break;
	}
}

/*
=================
BOTS_NurseCommandsMenu_Init
=================
*/
void BOTS_NurseCommandsMenu_Init() 
{
	int y;

	memset( &s_nurse, 0 ,sizeof(nurseCommands_t) );
	s_nurse.menu.wrapAround = qtrue;
	s_nurse.menu.fullscreen = qfalse;

	y = 96;
	s_nurse.title.generic.type	= MTYPE_PTEXT;
	s_nurse.title.generic.flags	= QMF_CENTER_JUSTIFY;
	s_nurse.title.generic.x		= 320;
	s_nurse.title.generic.y		= y;
	s_nurse.title.string		= "NURSE COMMANDS MENU";
	s_nurse.title.color			= color_bots_menu;
	s_nurse.title.style			= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_nurse.create.generic.type		= MTYPE_PTEXT;
	s_nurse.create.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_nurse.create.generic.x		= 320;
	s_nurse.create.generic.y		= y;
	s_nurse.create.generic.id		= BOTS_NURSE_CREATE;
	s_nurse.create.generic.callback	= BOTS_NurseCommandsMenu_Event; 
	s_nurse.create.string			= "CREATE ITEMS - create";
	s_nurse.create.color			= color_bots_menu;
	s_nurse.create.style			= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 1) {
		s_nurse.create.generic.flags |= QMF_GRAYED;
	}

	y += BOTS_VERTICAL_SPACING;
	s_nurse.poison.generic.type		= MTYPE_PTEXT;
	s_nurse.poison.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_nurse.poison.generic.x		= 320;
	s_nurse.poison.generic.y		= y;
	s_nurse.poison.generic.id		= BOTS_NURSE_POISON;
	s_nurse.poison.generic.callback	= BOTS_NurseCommandsMenu_Event; 
	s_nurse.poison.string			= "TOGGLE POISON - poison";
	s_nurse.poison.color			= color_bots_menu;
	s_nurse.poison.style			= UI_CENTER|UI_SMALLFONT;

	y += BOTS_VERTICAL_SPACING;
	s_nurse.heal.generic.type		= MTYPE_PTEXT;
	s_nurse.heal.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_nurse.heal.generic.x			= 320;
	s_nurse.heal.generic.y			= y;
	s_nurse.heal.generic.id			= BOTS_NURSE_HEAL;
	s_nurse.heal.generic.callback	= BOTS_NurseCommandsMenu_Event; 
	s_nurse.heal.string				= "HEALING DEVICE - heal";
	s_nurse.heal.color				= color_bots_menu;
	s_nurse.heal.style				= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 4) {
		s_nurse.heal.generic.flags |= QMF_GRAYED;
	}

	y += BOTS_VERTICAL_SPACING;
	s_nurse.healradius.generic.type		= MTYPE_PTEXT;
	s_nurse.healradius.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_nurse.healradius.generic.x		= 320;
	s_nurse.healradius.generic.y		= y;
	s_nurse.healradius.generic.id		= BOTS_NURSE_HEALRADIUS;
	s_nurse.healradius.generic.callback	= BOTS_NurseCommandsMenu_Event; 
	s_nurse.healradius.string			= "HEAL SURROUNDING PLAYERS - healradius";
	s_nurse.healradius.color			= color_bots_menu;
	s_nurse.healradius.style			= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 2) {
		s_nurse.healradius.generic.flags |= QMF_GRAYED;
	}

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_nurse.cancel.generic.type		= MTYPE_PTEXT;
	s_nurse.cancel.generic.flags	= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_nurse.cancel.generic.x		= 320;
	s_nurse.cancel.generic.y		= y;
	s_nurse.cancel.generic.id		= BOTS_CANCEL;
	s_nurse.cancel.generic.callback	= BOTS_NurseCommandsMenu_Event; 
	s_nurse.cancel.string			= "CANCEL";
	s_nurse.cancel.color			= color_bots_menu;
	s_nurse.cancel.style			= UI_CENTER|UI_SMALLFONT;

	Menu_AddItem( &s_nurse.menu, &s_nurse.title );
	Menu_AddItem( &s_nurse.menu, &s_nurse.create );
	Menu_AddItem( &s_nurse.menu, &s_nurse.poison );
	Menu_AddItem( &s_nurse.menu, &s_nurse.heal );
	Menu_AddItem( &s_nurse.menu, &s_nurse.healradius );
	Menu_AddItem( &s_nurse.menu, &s_nurse.cancel );
}

void BOTS_NurseCommandsMenu_f( void ) 
{
	// force as top level menu
	uis.menusp = 0;  

	// set menu cursor to a nice location
	uis.cursorx = 319;
	uis.cursory = 80;

	// setup the menu structure
	BOTS_NurseCommandsMenu_Init();

	// show the menus
	UI_PushMenu( &s_nurse.menu );
}
